<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
  protected function _initEnvironment() 
  {
  	date_default_timezone_set('America/Caracas');
  	Zend_Registry::set('locale', 'es_VE');
  	$autoloader = Zend_Loader_Autoloader::getInstance();
  	$autoloader->registerNamespace('Gtux_');
  	Zend_Registry::set('salt', '23d3fd70670ef68be4dabab84ff59f8a');
  }
  
  protected function _initView() 
  {
    // Initialize the view
    $view = new Zend_View();
    $view->doctype('XHTML1_STRICT');
    $view->headTitle('GtuxBox');
    $view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
    $view->env = APPLICATION_ENV;
    Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
    //Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
    // Add it to the View Renderer
    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
    $viewRenderer->setView($view);
    // return it so it can be stored by the bootstrap
    return $view;
  }
    
  protected function _initDb() 
  {
    $profiler = new Zend_Db_Profiler_Firebug('GtuxBox Queries');
    $profiler->setEnabled(true);
    $plugin   = $this->getPluginResource('db');
    $db       = $plugin->init();
    $db->setProfiler($profiler);
    return $db;
  }

  protected function _initLogger() 
  {
    $logger  = new Zend_Log();
    $logger->addPriority('trace', 9);
    
    $writter = new Zend_Log_Writer_Firebug();
    $writter->setPriorityStyle(9, 'TRACE');
    $filter  = new Zend_Log_Filter_Priority(Zend_Log::DEBUG);
    $writter->addFilter($filter);
    $logger->addWriter($writter);
    
    /*if (APPLICATION_ENV == 'production')
    {*/
      $file  = APPLICATION_PATH.DIRECTORY_SEPARATOR.'logs';
      $file .= DIRECTORY_SEPARATOR.'logs.txt';
      $writter = new Zend_Log_Writer_Stream($file);
      $filter  = new Zend_Log_Filter_Priority(Zend_Log::WARN);
      $writter->addFilter($filter);
      $logger->addWriter($writter);
    //}
    Zend_Registry::set('logger', $logger);
    return $logger;
  }
  
  protected function _initSession() 
  {
    $plugin = $this->getPluginResource('session');
    $options = $plugin->getOptions();
    Zend_Registry::set('ns', $options['name']);
    $session = $plugin->init();
    Zend_Session::start();
    Zend_Session::registerValidator(new Zend_Session_Validator_HttpUserAgent());
    new Zend_Session_Namespace($options['name']);
  	return $session;
  }
    
}

?>